fix(router): securely check path for proper destination #1133
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The router previously checked whether a path contained a route key. This check was insufficient, as it allowed a route configured as such:
'/admin': 'http://localhost:4002',
to be accessed to be accessible by requesting
/some/public/path?q=/admin
, which would match and route the request to localhost:4002.If http-proxy-middleware is in front of a firewall which restricts access to /admin, this could have allowed unauthorized access to the admin route.
Given the following options:
it was previously possible to run
curl 'http://localhost:3000/some/public/path?q=/admin
to access the/admin
endpoint.How has this been tested?
Added testcases + manually.